<?php 
header('Content-type:text/html;charset=utf-8');
    $input = file_get_contents("php://input"); //½ÓÊÕPOSTÊý¾Ý
     /*$input = '{
     	"notifyType":"deviceDatasChanged",
     	"requestId":null,
     	"deviceId":"6f86ea56-0884-4b8e-9395-b0a6da0aa1c6",
     	"gatewayId":"6f86ea56-0884-4b8e-9395-b0a6da0aa1c6",
     	"services":[
	     	{
	     		"serviceId":"SQVH75",
		     	"serviceType":"SQVH75",
		     	"data":{
		     		"Alarm_on":0,
		     		"Alarm_fire":0,
		     		"Alarm_check":0,
		     		"Alarm_battery":0,
		     		"Alarm_fault":0,
		     		"Base_apart":0,
		     		"Base_lost":0,
		     		"Base_temperature":0,
		     		"Base_battery":0,
		     		"Base_Other":0
		     	},
	     		"eventTime":"20180411T042956Z"
    	 	}
     	]
    }';*/
        if($input){
	    	$arr = json_decode($input,true);
	    	echo '<pre>';
	    	print_r($arr);
	    	$res = to_url('https://nb.777iot.com:443/api/test',http_build_query($arr));
	    	echo $res;	
		}
	
	function to_url($url, $data='')
    {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
        if (!empty($data)){
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS,$data);
        }
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return $output;
    }
  
